<?php
namespace Home\Controller;
use Think\Controller;
vendor('taobao.TopSdk');//引入淘宝SDK

class 	PrintController extends Controller {
	
	public function __construct() {
		parent::__construct();
		$ti = M('ti') -> where("user_id = '".$_SESSION['user']['id']."'") -> find();
		
		if(empty($ti) || empty($_SESSION['user']['id']))
		{
			$this->redirect('Home/Login/login');
		}
    } 
	 
	/*public function __construct() {
		parent::__construct();
		if(empty($_SESSION['visitor_id']))
		{
			header('Location: http://container.open.taobao.com/container?appkey=23344775');
		}
    }*/
		public function daifa(){
			$data['daifa']=empty($_REQUEST['daifa'])?"":$_REQUEST['daifa'];
			$tids=empty($_REQUEST['tids'])?"":$_REQUEST['tids'];
			$tid = explode(",",trim($tids,","));
			if($tid){
				$str='';
				foreach($tid as $val){
					$res = M('orders') -> where("tid = '$val'") -> save($data);
					if($res!==false){
						
					}else{
						$str .= $val."选择代发失败</br>";
					}
				}
				if(empty($str)){
					$rest['msg'] = "success";
					
				}else{
					$str.="其余选择代发成功";
					$rest['msg'] = $str;
				}
				echo $rest['msg'];
			}
		}
		
	
		public function group_del(){  
			$shouquan = M('shouquan');
			$find =  $shouquan -> where("visitor_id = ". $_SESSION['user']['id']) -> field('group_id,grouper') -> find();
			if($find['grouper'] == '1'){
				$del['group_id'] = '';
				$del['grouper']  = '';
				$res = $shouquan -> where("group_id = '".$find['group_id']."'") -> save($del);
				
			}else{
				$del['group_id'] = '';
				$res = $shouquan -> where("visitor_id = ". $_SESSION['user']['id']) -> save($del);
			}
			if($res){
				$data['resu'] = 'success';
			}else{
				$data['resu'] = 'error';	
			}
			
			echo json_encode($data);
			die;    
		}
		
	
		public function group(){
			$group = trim($_GET['group_id']);
			
			$info['group_id'] = $group;
			$info['grouper']  = '';
			$group_arr	=	explode('-',$group);
			if($group_arr[0] == $_SESSION['user']['id']){
				$data['resu'] = 'error';
			}else{
				$res = M('shouquan') -> where("visitor_id = ". $_SESSION['user']['id']) -> save($info);
				if($res){
					$data['resu'] = 'success';
				}else{
					$data['resu'] = 'error1';	
				}
			}
			echo json_encode($data);
			die; 
		}
	
		public function guanlian(){
			$group = trim($_GET['group']);
			$yzm   = trim($_GET['yzm']);
			$res = M('shouquan') -> field('group_id,visitor_nick') -> where("group_id = '$group' and send_yzm = '$yzm' and grouper = '1'") -> find();
			if($res){
				$data['resu'] = 'success';
				$data['group_id']	=	$res['group_id'];
				$data['visitor_nick']	=	$res['visitor_nick'];
			}else{
				$data['resu'] = 'error';	
			}
			
			echo json_encode($data);
			die;
		} 
		
		
		public function tongzu(){ 
			$rand['group_id'] = $_SESSION['user']['id']."-".time().rand(1000,9999);
			$rand['grouper'] = '1';
			$res = M('shouquan') -> where("visitor_id = ". $_SESSION['user']['id']) -> save($rand);
			if($res){
				$data['resu'] = 'success';
				$data['group_id'] = $rand['group_id'];
				
			}else{
				$data['resu'] = 'error';
				$data['msg'] = '';
			}
			if($data['resu'] == 'success'){
				$shouquan =  M('shouquan') -> field('top_session') -> where("visitor_id = ". $_SESSION['user']['id']) -> find();
	
				$uid = '188592';		//数字用户名
				$pwd = '123456';		//密码
				$mobile	 = taobao_address(base64_decode($shouquan['top_session']));	//号码
				$rand = rand(100000,999999);
				$content = "你好，你的短信验证码为:$rand,请在15分钟内完成验证";		//内容
				//即时发送
				$res = sendSMS($uid,$pwd,$mobile,$content);
				if($res == '发送成功!'){
					$send_data['send_yzm'] = $rand;
					$resu = M('shouquan') -> where("visitor_id = ". $_SESSION['user']['id']) -> save($send_data);
					$data['msg'] = '验证码已发送至'.$mobile.',请注意查收!(请在绑定店铺时填写该验证码！)';
				}else{
					$data['resu'] = 'error';
					$data['msg'] = '验证码发送失败:'.$res;
				}
			}
			echo json_encode($data);
			die;
		}
		
	   public function guanli(){
		    $pageNo=empty($_REQUEST['pageNo'])?1:$_REQUEST['pageNo'];
			$pageSize=empty($_REQUEST['pageSize'])?10:$_REQUEST['pageSize'];
		    $visitor_id = $_SESSION['user']['id'];
			$shouquan = M('shouquan');
			$address  = M('address');
			$join = "address as a on a.visitor_id = s.visitor_id";
			$is_group = $shouquan -> where('visitor_id = '.$visitor_id) -> field('group_id') -> find();
			if($is_group['group_id']){
				
				$address_all = $shouquan -> alias(' as s') -> where("group_id ='".$is_group['group_id']."' and is_default = '1'") -> field('a.* , visitor_nick , deadline , group_id') -> join($join) -> select();
			}else{
				$address_all = $shouquan -> alias(' as s') -> where("s.visitor_id ='".$visitor_id."' and is_default = '1'") -> field('a.* , visitor_nick , deadline , group_id') -> join($join) -> select();
			}
			$count['count']=count($address_all);
			$count['countpage']=ceil($count['count']/$pageSize);
			if($pageNo>=$count['countpage']){ 
				$pageNo=$count['countpage'];
			}
			if($pageNo<=0){
				$pageNo=1;
			}
			if($is_group['group_id']){
				
				$address_all = $shouquan -> alias(' as s') -> where("group_id ='".$is_group['group_id']."' and is_default = '1'") -> field('a.* , visitor_nick , deadline , group_id') -> join($join) -> limit(($pageNo-1)*$pageSize,$pageSize)-> order("id desc") -> select();
			}else{
				$address_all = $shouquan -> alias(' as s') -> where("s.visitor_id ='".$visitor_id."' and is_default = '1'") -> field('a.* , visitor_nick , deadline , group_id') -> join($join) -> limit(($pageNo-1)*$pageSize,$pageSize)-> order("id desc") -> select();
			}
			
			$count['pageSize']=$pageSize;
			$count['pageNo']=$pageNo;
			$count['num']=$count['countpage']-4;
			$top = M('shouquan') -> field('top_session') -> where("visitor_id = '".$_SESSION['user']['id']."'") -> find();
			
			/*$phone = taobao_address($top['top_session']);
			$send  = send($top['top_session'],$phone);*/
			$this -> assign('count',$count);
			$this -> assign('address',$address_all);
			$this -> display(); 
		
	   }
	   
	   
	    /* 打印 */
		public function template_print(){
			$visitor_id = $_SESSION['user']['id'];    
			$template_id=$_REQUEST['template_id'];
			$printer=$_REQUEST['printer'];
			$exclude=$_REQUEST['exclude'];   //是否排除已打印的标记
			$merge=$_REQUEST['merge'];   //是否排除已打印的标记
			$address_id=$_REQUEST['address_id'];   //是否排除已打印的标记
			$mids=trim($_REQUEST['mids'],'|');
			$mids=explode('|',$mids);
			
			$template=M('print_template');
			$template_list=$template->field('content')->where("id=".$template_id)->find();
			$content=$template_list['content'];
			
			$newcontent=$content;
			
			/* 发货地址 */
			$address=D('address');
		    $addressinfo=$address->address_info($address_id);
			
			$shipping_address=$addressinfo['province'].' '.$addressinfo['city'].' '.$addressinfo['district'].' '.$addressinfo['town'].' '.$addressinfo['address'];
			
			$orders=D('orders');
			$trades=M('trades');
			
			//echo "LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));";
			echo "LODOP=GetLodop();";
			
			 
			foreach($mids as $k => $v){
				$content=$newcontent;
				
				$mid_arr=explode(':',trim($v,',')); 
				$mid=$mid_arr[0];
				$oids=explode(',',$mid_arr[1]);
				
				/* 获取商品信息，相同的商品合并 */
				$arr=array();
				foreach($oids as $ko=>$vo)
				{
					$orders_info=$orders->order_info_oid($vo);
					
					$name=empty($orders_info['short_name'])?(empty($orders_info['outer_iid'])?$orders_info['title']:$orders_info['outer_iid']):$orders_info['short_name'];
					if(in_array($name,$arr))
					{
						$arr[$ko]['shifa']=$arr[$name]['shifa']+$orders_info['shifa'];
					}
					else 
					{
						$arr[$ko]['shifa']=$orders_info['shifa'];
						$arr[$ko]['outer_iid']=$orders_info['outer_iid'];
						$arr[$ko]['short_name']=empty($orders_info['short_name'])?$orders_info['title']:$orders_info['short_name'];
						
					}
				  
				}
				
				/* 商品信息 */
				$goods_info='';
				$name_nowrap='';
				$name_wrap='';
				$outer_iid_nowrap='';
				$outer_iid_wrap='';
				$name_num_nowrap='';
				$name_num_wrap='';
				$outer_iid_num_nowrap='';
				$outer_iid_num_wrap='';
				foreach($arr as $ka=>$va)
				{   
					$goods_info.=$ka.' * '.$va."   ";
					$name_nowrap.=$va['short_name']."   ";
					$name_wrap.=$va['short_name']."\n";
					$outer_iid_nowrap.=$va['outer_iid']."   ";
					$outer_iid_wrap.=$va['outer_iid']."\n";
					$name_num_nowrap.=$va['short_name'].' * '.$va['shifa']."   ";
					$name_num_wrap.=$va['short_name'].' * '.$va['shifa']."\n";
					$outer_iid_num_nowrap.=$va['outer_iid'].' * '.$va['shifa']."   ";
					$outer_iid_num_wrap.=$va['outer_iid'].' * '.$va['shifa']."\n";
				}
				
				//$orders_info=$orders->get_order_info($value);
				
				if($orders_info['is_print']==0 || $exclude=='false')
				{  
					$content=str_replace('收货人-姓名',$orders_info['receiver_name'],$content);
					$content=str_replace('省(收)',$orders_info['receiver_state'],$content);
					$content=str_replace('市(收)',$orders_info['receiver_city'],$content);
					$content=str_replace('区县(收)',$orders_info['receiver_district'],$content);
					$content=str_replace('收货人-地址(无省市区)',$orders_info['receiver_address'],$content);
					$content=str_replace('收货人-地址(有省市区)',$orders_info['receiver_state'].$orders_info['receiver_city'].$orders_info['receiver_district'].$orders_info['receiver_address'],$content);
					if(empty($orders_info['receiver_mobile']))
					{
						$content=str_replace('收货人-手机和电话',$orders_info['receiver_phone'],$content);
					    $content=str_replace('收货人-电话',$orders_info['receiver_phone'],$content);
					}
					else
					{
						$content=str_replace('收货人-手机和电话',$orders_info['receiver_mobile'],$content);
					    $content=str_replace('收货人-电话',$orders_info['receiver_mobile'],$content);
					}
					
					
					$content=str_replace('发货人-姓名',$addressinfo['contact'],$content);
					$content=str_replace('发货人-始发地',$addressinfo['province'],$content);
					$content=str_replace('省(发)',$addressinfo['province'],$content);
					$content=str_replace('市(发)',$addressinfo['city'],$content);
					$content=str_replace('区县(发)',$addressinfo['district'],$content);
					$content=str_replace('发货人-地址(无省市区)',$addressinfo['address'],$content);
					$content=str_replace('发货人-地址(有省市区)',$addressinfo['province']." ".$addressinfo['city']." ".$addressinfo['district']." ".$addressinfo['town']." ".$addressinfo['address'],$content);
					$content=str_replace('发货人-手机和电话',$addressinfo['phone'],$content); 
					
					/* 订单信息 */
					$content=str_replace('买家留言',$orders_info['buyer_message'],$content); 
					$content=str_replace('卖家备注',$orders_info['seller_memo'],$content); 
					$content=str_replace('订单编号',$orders_info['tid'],$content); 
					$content=str_replace('拍下时间',$orders_info['created'],$content); 
					$content=str_replace('付款时间',$orders_info['pay_time'],$content);
					
					/* 商品信息 */
					$content=str_replace('宝贝简称(不换行)',trim($name_nowrap),$content);
					$content=str_replace('宝贝简称(换行)',trim($name_wrap),$content);
					$content=str_replace('商家编码(不换行)',trim($outer_iid_nowrap),$content);
					$content=str_replace('商家编码(换行)',trim($outer_iid_nwrap),$content);
					$content=str_replace('宝贝简称+数量(不换行)',trim($name_num_nowrap),$content);
					$content=str_replace('宝贝简称+数量(换行)',trim($name_num_wrap),$content);
					$content=str_replace('商家编码+数量(不换行)',trim($outer_iid_num_nowrap),$content);
					$content=str_replace('商家编码+数量(换行)',trim($outer_iid_num_wrap),$content);
					
					 
					/* 其它信息 */
					$content=str_replace('店铺名称',$orders_info['shop'],$content);
					$content=str_replace('卖家昵称',$orders_info['seller_nick'],$content);
					$content=str_replace('运单号码',$orders_info['invoice_no'],$content);
					$content=str_replace('年月日时分秒',date('Y-m-d H:i:s'),$content);
					$content=str_replace('年月日',date('Y-m-d'),$content);
					  
					  
					/*$content=str_replace('1234785690',$orders_info['invoice_no'],$content);
					$content=str_replace('1237894560',$orders_info['invoice_no'],$content);
					$content=str_replace('0123456789',$orders_info['package_center_code'],$content);
					$content=str_replace('目的地(大头笔)',$orders_info['short_address'],$content);
					$content=str_replace('集包地名称',$orders_info['package_center_name'],$content);
					*/

					$content=str_replace('("ali_waybill_product_type","具体内容")','("ali_waybill_consignee_address","")',$content);
					$content=str_replace('("ali_waybill_short_address","具体内容")','("ali_waybill_send_name","'.$orders_info["short_address"].'")',$content);
					$content=str_replace('("ali_waybill_package_center_name","具体内容")','("ali_waybill_send_phone","'.$addressinfo["package_center_name"].'")',$content);
					$content=str_replace('("ali_waybill_package_center_code","具体内容")','("ali_waybill_shipping_address","'.$addressinfo["package_center_code"].'")',$content);
					$content=str_replace('("ali_waybill_waybill_code","具体内容")','("ali_waybill_waybill_code","'.$orders_info['invoice_no'].'")',$content);
					$content=str_replace('("ali_waybill_consignee_name","具体内容")','("ali_waybill_consignee_name","'.$orders_info['receiver_name'].'")',$content);
					if(empty($orders_info['receiver_mobile']))
					{
						$content=str_replace('("ali_waybill_consignee_phone","具体内容")','("ali_waybill_consignee_phone","'.$orders_info['receiver_phone'].'")',$content);
					} 
					else
					{
						$content=str_replace('("ali_waybill_consignee_phone","具体内容")','("ali_waybill_consignee_phone","'.$orders_info['receiver_mobile'].'")',$content);
					}
					$content=str_replace('("ali_waybill_consignee_address","具体内容")','("ali_waybill_consignee_address","'.$orders_info['receiver_address'].'")',$content);
					$content=str_replace('("ali_waybill_send_name","具体内容")','("ali_waybill_send_name","'.$orders_info["shop"].'")',$content);
					$content=str_replace('("ali_waybill_send_phone","具体内容")','("ali_waybill_send_phone","'.$addressinfo["phone"].'")',$content);
					$content=str_replace('("ali_waybill_shipping_address","具体内容")','("ali_waybill_shipping_address","'.$shipping_address.'")',$content);
					$content=str_replace('("ali_waybill_service","具体内容")','("ali_waybill_shipping_address","")',$content);
					
	
					if($k!=0)
					{
					  $content=explode(';',$content);
						if(strpos($content[0],'PRINT_INITA')){
						  unset($content[0]);
						}
					  $content=implode(';',$content);
					}
					echo "LODOP.SET_PRINT_IDENTITY('AppKey=23416550&Seller_ID=".$visitor_id."');";
					echo $content;
					echo 'LODOP.SET_PRINTER_INDEX('.$printer.');LODOP.NewPage();';
					
					/* 更新订单为已打印  */
					$data['is_print']=1;
					$visitor_id	=	$_SESSION['user']['id'];
					$shouquan = M('shouquan') -> field('group_id') -> where("visitor_id = '$visitor_id'") -> find();
					if($shouquan['group_id']){
						 $shouquan2 = M('shouquan') -> field('visitor_id') -> where("group_id = '".$shouquan['group_id']."'") -> select(); 	
						 foreach($shouquan2 as $k=> $val){
							 if($k == '0'){
								 $s_str = "'".$val['visitor_id']."'";
							 }else{
								 $s_str .= ","."'".$val['visitor_id']."'";
							 }
						 }
						 
					 }	
					foreach($oids as $oid)
					{
						if($shouquan['group_id']){
							$res=M('orders')->where("oid='$oid' and visitor_id in($s_str)")->save($data);
						}else{
							$res=M('orders')->where("oid='$oid' and visitor_id = '$visitor_id'")->save($data);
						}
					}
					
				}
				
				 
			}
			
			if($content==$newcontent)
			{
				echo "无未打印的订单";
			}
			else
			{
				echo "LODOP.PREVIEW();";
				//echo "LODOP.PRINT();";
			}
			
		}
		 
		
	    /* 打单发货页面 */	
		public function print_order(){
			$where['visitor_id'] = $_SESSION['user']['id'];
			
			$pageNo=empty($_REQUEST['pageNo'])?1:$_REQUEST['pageNo'];
			$pageSize=empty($_REQUEST['pageSize'])?10:$_REQUEST['pageSize'];
			$shoptitle=empty($_REQUEST['shoptitle'])?'':$_REQUEST['shoptitle'];
			$status=empty($_REQUEST['status'])?'WAIT_SELLER_SEND_GOODS':$_REQUEST['status'];
			$starttime=empty($_REQUEST['starttime'])?'':trim($_REQUEST['starttime']);
			$endtime=empty($_REQUEST['endtime'])?'':trim($_REQUEST['endtime']);
			//$name=empty($_REQUEST['name'])?'t.pay_time':$_REQUEST['name'];
			//$asc=empty($_REQUEST['asc'])?'desc':trim($_REQUEST['asc']);
			
			$outer_iid	=	empty($_REQUEST['outer_iid'])?'':trim($_REQUEST['outer_iid']);
			$shifa		=	empty($_REQUEST['shifa'])?'':trim($_REQUEST['shifa']);
			$seller_flag=	empty($_REQUEST['seller_flag'])?'':trim($_REQUEST['seller_flag']);
			$tid=empty($_REQUEST['tid'])?'':trim($_REQUEST['tid']);
		    $receiver_name=empty($_REQUEST['receiver_name'])?'':trim($_REQUEST['receiver_name']);
			$kuaidi2=empty($_REQUEST['kuaidi2'])?'':$_REQUEST['kuaidi2'];
			$kuaidi1=empty($_REQUEST['kuaidi1'])?'':$_REQUEST['kuaidi1'];
			$asc_sort=empty($_REQUEST['asc_sort'])?'pay_time|desc':trim($_REQUEST['asc_sort']);
			$sou_key=empty($_REQUEST['sou_key'])?'':trim($_REQUEST['sou_key']);
			
			//dump($asc_sort);
			$sort2 = explode("|",$asc_sort);
			
			$name = $sort2['0'];
			$asc  = $sort2['1'];
			
			$orders=D('orders');
			$res=$orders->order_list_print($pageNo,$pageSize,$name,$asc,'print','',$kuaidi1,$kuaidi2,$sou_key);
			
			$duo_count = $res['duo_count'];
			$dan_count = $res['dan_count'];
			$order_list=$res['order_list'];
		
			
			//$shop_list=M('shop')->where($where)->field("id,shop_name")->select();
			 
			$template=M('print_template'); 
			$template_list=$template->field('id,name,bgimg,content')->where("visitor_admin = ''")->order('type desc')->select();
			$template_dai	=	$template -> field('name,visitor_admin') -> where("visitor_admin != ''") -> select();
			
			 
			$address=D('address');
			$rea=$address->address_list();
			$address_list=$rea['address_list'];
			
			//$kuaidi2 ="{'all':0,'beizhu':1,'baoyou':0,'bubaoyou':0,'weifukuan':0,'hong':0,'huang':0,'lv':0,'lan':0,'zi':0}";
		   
			//var_dump($order_list); 
			$this -> assign('sou_key',$sou_key);
			$this -> assign('asc_sort',$asc_sort);
			$this -> assign('duo_count',$duo_count);
			$this -> assign('dan_count',$dan_count);
			$this -> assign('kuaidi1',$kuaidi1);
			$this -> assign('kuaidi2',$kuaidi2);
			$this -> assign('order_list',$order_list);
			$this -> assign('shop_list',$shop_list);
			$this -> assign('template_dai',$template_dai);
			$this -> assign('template_list',$template_list);
			$this -> assign('address_list',$address_list);
			$this -> assign('count',$res['count']); 
			$this -> assign('data',$res['data']);
			$this -> display();
	  
		}
		
	/* 生成运单号*/	
   	public function get_ydh(){
		$visitor_id = $_SESSION['user']['id'];    
		$orders=D('orders');
		$trades=D('trades');
		$template_id=empty($_REQUEST['template_id'])?'':trim($_REQUEST['template_id']);
		$merge=empty($_REQUEST['merge'])?'':trim($_REQUEST['merge']);
	    $tids=empty($_REQUEST['tids'])?'':trim($_REQUEST['tids']);
		$ydh=empty($_REQUEST['ydh'])?'':trim($_REQUEST['ydh']);
		$chazhi=empty($_REQUEST['chazhi'])?'':trim($_REQUEST['chazhi']);
		$mids=empty($_REQUEST['mids'])?'':trim($_REQUEST['mids']);
		$mids=explode('|',trim($mids,'|'));
		$ydh_=substr($ydh,0,-8);
        $ydh_n=substr($ydh,-8);
		$template=M('print_template');
		$templateinfo=$template->field('id,code,name')->where("id=".$template_id)->find();
		if(!empty($mids))
		{
			foreach($mids as $k=>$v)
			{    
			    $mid_arr=explode(':',trim($v,','));
				$mid=$mid_arr[0];
				$oids=explode(',',$mid_arr[1]);
				
				$data['logistics_company']=$templateinfo['name'];
				$data['logistics_code']=$templateinfo['code'];
				$data['invoice_no']=$ydh_.($ydh_n+$chazhi*$k);
				$visitor_id	=	$_SESSION['user']['id'];	
				if($shouquan['group_id']){
					$shouquan2 = M('shouquan') -> field('visitor_id') -> where("group_id = '".$shouquan['group_id']."'") -> select(); 	
					foreach($shouquan2 as $k=> $val){
						if($k == '0'){
							$s_str = "'".$val['visitor_id']."'";
				  		}else{
					  		$s_str .= ","."'".$val['visitor_id']."'";
				  		}
			   		}
		   		}
				foreach($oids as $oid)
				{
					if($$shouquan['group_id']){
						$res=$orders->where("oid='$oid' and visitor_id in($s_str)")->save($data);
					}else{
						$res=$orders->where("oid='$oid' and visitor_id ='$visitor_id'")->save($data);
					}
					if($res!==false)
					{
						$result[$k]['invoice_no']=$data['invoice_no'];
						$result[$k]["mid"] = $mid;
					} 
				}
			}
		}
		echo json_encode($result);
		
    }
		
	/* 获取电子面单号*/	
   	public function get_dzmd(){
		$visitor_id = $_SESSION['user']['id'];    
		$orders=D('orders');
		
		$template_id=empty($_REQUEST['template_id'])?'':trim($_REQUEST['template_id']);
	    $tids=empty($_REQUEST['tids'])?'':trim($_REQUEST['tids']);
		$merge=empty($_REQUEST['merge'])?'':trim($_REQUEST['merge']);
		$address_id=empty($_REQUEST['address_id'])?'':trim($_REQUEST['address_id']);
		
		$mids=empty($_REQUEST['mids'])?'':trim($_REQUEST['mids']);
		$mids=explode('|',trim($mids,'|'));
		
		$template=M('print_template');
		$templateinfo=$template->field('id,code,name')->where("id=".$template_id)->find();
		$address=D('address');
		$addressinfo=$address->address_info($address_id);
		
       
		if(!empty($mids))
		{
			foreach($mids as $k=>$v)
			{  
				
			   $mid_arr=explode(':',trim($v,','));
			   $mid=$mid_arr[0];
			   $oids=explode(',',$mid_arr[1]);
			  
			   $orderinfo=$orders->order_info_oid($oids[0]);
			  
			   $info=$orderinfo['receiver_name'].' '.$orderinfo['receiver_state'].' '.$orderinfo['receiver_city'].' '.$orderinfo['receiver_district'].' '.$orderinfo['receiver_town'].' '.$orderinfo['receiver_address'];
			   
			   $data['province']=$orderinfo['receiver_state'];
			   $data['city']=$orderinfo['receiver_city'];
			   $data['area']=$orderinfo['receiver_district'];
			   $data['full_address']=$orderinfo['receiver_address'];
			   $data['fullname']=$orderinfo['receiver_name'];
			   $data['mobile']=$orderinfo['receiver_mobile'];
			   $data['tid']=$orderinfo['tid'];
			   $data['code']=$templateinfo['code'];
			   $data['title']=$orderinfo['title'];
			   $data['num']=$orderinfo['num'];
			   $data['oid']=$orderinfo['oid'];
				
			   /* 发货地址 */
			   $data['shipping_address']['address_detail'] = $addressinfo['address'];
			   $data['shipping_address']['area'] = $addressinfo['district'];
			   $data['shipping_address']['city'] = $addressinfo['city'];
			   $data['shipping_address']['province'] = $addressinfo['province'];
			   $data['shipping_address']['town'] = $addressinfo['town'];
	 
			   $re=$this->getWaybill_code($data);
			   $new_info=$re->waybill_apply_new_cols->waybill_apply_new_info[0];
			 
			   $waybill_code=$re->waybill_apply_new_cols->waybill_apply_new_info[0]->waybill_code;
			   if($waybill_code)
			   {   
				  $update['logistics_company']=$templateinfo['name'];
				  $update['logistics_code']=$templateinfo['code'];
				  $update['invoice_no']=$waybill_code;
				  $update['package_center_code']=$new_info->package_center_code;
				  $update['package_center_name']=$new_info->package_center_name;
				  $update['short_address']=$new_info->short_address;
				  $visitor_id	=	$_SESSION['user']['id'];
				  $where = "oid='$oid' ";
				  $shouquan = M('shouquan') -> field('group_id') -> where("visitor_id = '$visitor_id'") -> find();
				  if($shouquan['group_id']){
					   $shouquan2 = M('shouquan') -> field('visitor_id') -> where("group_id = '".$shouquan['group_id']."'") -> select(); 	
					   foreach($shouquan2 as $k=> $val){
						   if($k == '0'){
							   $s_str = "'".$val['visitor_id']."'";
						   }else{
							   $s_str .= ","."'".$val['visitor_id']."'";
						   }
					   }
					   $where.= " and visitor_id in($s_str)";
				   }else{
					   $where .= " and visitor_id = '$visitor_id'";
				   }		
				   foreach($oids as $oid)
				   {
					   $res=M('orders')->where($where)->save($update);
				
					   if($res!==false)
					   {
						   $result[$k]['invoice_no']=	$waybill_code;
						   $result[$k]['mid']	=	$mid;
					   }
				   }
				   
			   } 
			   else
			   {
				  $result['error']=$re->sub_msg; 
			   } 
				   			  
			} 
		}
		 
		echo json_encode($result);
		
    }
	
	function getWaybill_code($data){
		
        //$data['cp_code'] = 'YTO';
		
        /*$data['shipping_address']['address_detail'] = '民治街道民乐翠园12栋104';
        $data['shipping_address']['area'] = '龙华新区';
        $data['shipping_address']['city'] = '深圳市';
        $data['shipping_address']['province'] = '广东省';
        $data['shipping_address']['town'] = '';*/
		
		$visitor_id = $_SESSION['user']['id'];
		$shopinfo=M('shouquan')->field('top_session,visitor_id')->where("visitor_id='$visitor_id'")->find(); 
		 
		$data['cp_code'] = $data['code'];
		
		$data['trade_order_info_cols'] = array(
            0=>array(
                'consignee_address'=>array(
                    'address_detail' => $data['full_address'],//买家详细地址
                    'area' => $data['area'],//买家地区 
                    'city' => $data['city'],//买家城市
                    'province' => $data['province'],//买家省份
                    'town' => '',//买家街道
                ),
                'consignee_name' => $data['fullname'],//买家姓名
                'consignee_phone' => $data['mobile'],//买家手机号码
                'logistics_service_list' => array(),
                'order_channels_type' => 'TB',
                'package_items' => array(
                    //0 => array('count'=>'1','item_name'=>'itemName0')
					0 => array('count'=>$data['num'],'item_name'=>$data['title'])
                ),
                'product_type' => 'STANDARD_EXPRESS',
               // 'real_user_id' => '039790269',//89346737
			   //'real_user_id' => '2126677632',
			   'real_user_id' => $shopinfo['visitor_id'],//
                //'send_name' => '殷小姐',//卖家姓名
                //'send_phone' => '18123910886',//卖家电话
                'trade_order_list' => array(
                    0 => $data['oid'] 
                ),
                //'volume' => '10',
               // 'weight' => '10'
            ),
        );
		
		 
		 
        $c = new \TopClient();
        //$c->appkey = "23444677";//23217234
        //$c->secretKey = "6a4a8631ce3c098105c6f917642dbe07";
		$c->appkey = "23416550";//23217234
        $c->secretKey = "ebbc68fc906b6436f76b4f9cda829976";
		$c->format="json";//var_dump($c);
        
        //$sessionKey = "610222424ef8cc433dd4f6ad60f27f2d1f0b27c50897e961039790269";
		//$sessionKey = "6100e18134be3693ce6e92ee261869ca51a7a2ae8e9cc012126677632";
		//$sessionKey = "6102102ef0156185ee1907866ced73054fc72aa346b3e3b2229336577";
        $req = new \WlbWaybillIGetRequest();//var_dump($req);
    	$req->setWaybillApplyNewRequest(json_encode($data));
        $resp = $c->execute($req, $shopinfo['top_session']);
		
        
	
        return  $resp;
      
        //self::sendOrders($tid,"",$resp->waybill_apply_new_cols->waybill_apply_new_info->waybill_code."");
    }
	
	

	
	/*  发货到淘宝 */
	public function send_goods(){
		$visitor_id = $_SESSION['user']['id'];   
		$tids=empty($_REQUEST['tids'])?'':trim($_REQUEST['tids']);
		$mids=empty($_REQUEST['mids'])?'':trim($_REQUEST['mids']);
	
		if(!empty($mids))
		{
			 
			$mids=trim($mids,'|');
			$mids=explode('|',$mids); 
			$shouquan = M('shouquan') -> field('group_id') -> where("visitor_id = '$visitor_id'") -> find();
			if($shouquan['group_id']){
				 $shouquan2 = M('shouquan') -> field('visitor_id') -> where("group_id = '".$shouquan['group_id']."'") -> select(); 	
				 foreach($shouquan2 as $k=> $val){
					 if($k == '0'){
						 $s_str = "'".$val['visitor_id']."'";
					 }else{
						 $s_str .= ","."'".$val['visitor_id']."'";
					 }
				 }
			 }	 
			foreach($mids as $k=>$v)
			{   	
				$mid_arr=explode(':',$v);
				$mid=$mid_arr[0];
				$oids=explode(',',trim($mid_arr[1],',')); 
				
			    $orders=D('orders');
				$trades=M('trades');
				$shop=D('shop');
				
				foreach($oids as $oid)
				{     
				    $field="t.title as shop, t.receiver_name,t.receiver_mobile,t.receiver_phone,t.receiver_state,t.receiver_city,t.receiver_district,t.receiver_town,t.receiver_address,".
					       "o.oid,o.tid,o.title,o.short_name,o.outer_iid,o.num,o.shifa,o.logistics_company,o.logistics_code,o.invoice_no,o.payment,o.visitor_id";
					if($shouquan['group_id']){
						$orderinfo=$trades->alias('as t')->join('orders as o on t.tid=o.tid')->field($field)->where("o.oid='$oid' and o.visitor_id in($s_str)")->find();
					}else{
				    	$orderinfo=$trades->alias('as t')->join('orders as o on t.tid=o.tid')->field($field)->where("o.oid='$oid' and o.visitor_id = '$visitor_id'")->find();
					}
					
					$shopinfo=M('shouquan')->field('id,top_session,visitor_id,visitor_nick')->where("visitor_id='".$orderinfo['visitor_id']."'")->find();
					
					if($orderinfo['send_status']=='success') //已发货成功的不再发货
					{
						$result[$oid]['send_status']='已发货成功';
					}
					elseif(empty($orderinfo['invoice_no'])) //无单号不能发货
					{
						$result[$oid]['send_status']='无单号不能发货';
					}
					else
					{     
					    $appkey = '23416550';
		                $secretkey = 'ebbc68fc906b6436f76b4f9cda829976';
		
						$c = new \TopClient;
						$c->appkey = $appkey;
						$c->secretKey = $secretkey;
						
						$req = new \LogisticsOfflineSendRequest;
						$req->setTid($orderinfo['tid']);
						$req->setSubTid($oid);
						$req->setIsSplit("1");
						$req->setOutSid($orderinfo['invoice_no']);
						$req->setCompanyCode($orderinfo['logistics_code']);
		 
						$resp = $c->execute($req, $shopinfo['top_session']);
						
						$is_success=(array)$resp->shipping->is_success;
						 			
						if($is_success[0])
						{   
							$result[$oid]['send_status']='发货成功';
							
							$data['status']='WAIT_BUYER_CONFIRM_GOODS';
							$data['send_status']='success';
							if($shouquan['group_id']){
								$reso=$orders->where("oid='$oid' and visitor_id in($s_str)")->save($data);
								$goodsinfo=M('goods')->field('id,code,stock')->where("code='".$orderinfo['outer_iid']."' and visitor_id in($s_str)")->find();
							}else{
								$reso=$orders->where("oid='$oid' and visitor_id = '$visitor_id'")->save($data);
								$goodsinfo=M('goods')->field('id,code,stock')->where("code='".$orderinfo['outer_iid']."' and visitor_id='".$visitor_id."'")->find();
							}
							
							
							if($goodsinfo)
							{
								$goods_stock['stock']=$goods['info']-$orderinfo['shifa'];
								$goods_stock['visitor_id']	=	$_SESSION['user']['id'];
								$where_in	=	"id = '".$goodsinfo['id']."'";
								if($shouquan['group_id']){
									$where_in .= " and visitor_id in($s_str)";
								}else{
									$where_in .= " and visitor_id = $visitor_id";
								}
								$reg=M('goods')->where($where_in)->save($goods_stock);   /* 发货减库存 */
								
								if($reg)
								{
									$log['shop']=$shopinfo['id'] ;
									$log['name']=$orderinfo['receiver_name'] ;
									$log['phone']=empty($orderinfo['receiver_phone'])?$orderinfo['receiver_mobile']:$orderinfo['receiver_mobile']." | ".$orderinfo['receiver_phone'] ;
									$log['address']=$orderinfo['receiver_state']." ".$orderinfo['receiver_city']." ".$orderinfo['receiver_district']." ".$orderinfo['town']." ".$orderinfo['address'] ;
									$log['goods_id']=$goodsinfo['id'];
									$log['outer_iid']=$orderinfo['outer_iid'] ;
									$log['num']=-$orderinfo['shifa'] ;
									$log['amount']=$orderinfo['payment'] ;
									$log['remarks']='发货减库存' ;
									$log['add_time']=date('Y-m-d H:i:s') ;
									$log['modify_time']=date('Y-m-d H:i:s') ;
									$log['tid']=$orderinfo['tid'] ;
									$log['oid']=$oid ;
									$log['visitor_id']=$visitor_id ; 
									  
									$rel=M('stock_log')->add($log);  /* 添加库存记录  */
								}
								
							}
								
							 
						}
						else
						{
							/* 更新订单发货状态  */
							$data['send_status']='fail';
							$visitor_id = $_SESSION['user']['id'];  
							if($shouquan['group_id']){
								$reso=$orders->where("oid='$oid' and visitor_id in($s_str)")->save($data);
							}else{
								$reso=$orders->where("oid='$oid' and visitor_id = '$visitor_id'")->save($data);
							}
							if($resp->sub_msg)
							{
							   $result[$oid]['send_status']	=(string)$resp->sub_msg;
							}
							elseif($resp->msg)
							{
							   $result[$oid]['send_status']	=(string)$resp->msg;
							}
							else
							{
								$result[$oid]['send_status']	=	"发货失败";
							}
								
						}
					}
				}
				
			}  
			echo json_encode($result);
		}
		
    }    
	
    /* 订单手动审核 */
   public function sd_shenhe()
   {
	   
		$visitor_id = $_SESSION['user']['id']; 
		$tids 		=  	I("tids");
		$tid_arr	=	explode(",",$tids);
		if(!empty($tid_arr))
		{
			$data['status'] = "WAIT_BUYER_CONFIRM_GOODS";
			$orders	=	M('orders');
			$trades	=	M('trades');
			$goods	=	M('goods');
			$stock	=	M('stock_log'); 
			$shop	=	M('shop');
			$shouquan = M('shouquan') -> field('group_id') -> where("visitor_id = '$visitor_id'") -> find();
			if($shouquan['group_id']){
				 $shouquan2 = M('shouquan') -> field('visitor_id') -> where("group_id = '".$shouquan['group_id']."'") -> select(); 	
				 foreach($shouquan2 as $k=> $val){
					 if($k == '0'){
						 $s_str = "'".$val['visitor_id']."'";
					 }else{
						 $s_str .= ","."'".$val['visitor_id']."'";
					 }
				 }
			 }
			foreach($tid_arr as $tid)
			{
				if($tid)
				{
					if($shouquan['group_id']){
						$ret=$trades->where("tid='$tid' and visitor_id in($s_str)")->save($data);
						$reo=$orders->where("tid='$tid' and visitor_id in($s_str) and (refund_status='NO_REFUND' or refund_status='CLOSED')")->save($data);
						$where = "t.visitor_id in($s_str) and t.tid='".$tid."' and (o.refund_status='NO_REFUND' or o.refund_status='CLOSED')";
					}else{
						$ret=$trades->where("tid='$tid' and visitor_id = '$visitor_id'")->save($data);
						$reo=$orders->where("tid='$tid' and visitor_id = '$visitor_id' and (refund_status='NO_REFUND' or refund_status='CLOSED')")->save($data);
						$where = "t.visitor_id = '$visitor_id' and t.tid='".$tid."' and (o.refund_status='NO_REFUND' or o.refund_status='CLOSED')";
					}
					$join="orders as o on o.tid=t.tid";
					$field="t.receiver_name,t.receiver_mobile,t.receiver_phone,t.receiver_state,t.receiver_city,t.receiver_district,t.receiver_town,t.receiver_address,t.title as shop,".
					       "o.outer_iid,o.title,o.num,o.shifa,o.payment,o.oid,o.refund_fee";
					$order_list=$trades->alias('as t')->join($join)->field($field)->where($where)->select();
					
					if($order_list)
					{
						foreach($order_list as $order)
						{
							$goodsinfo=$goods->field("id,stock,code")->where("code='".$order['outer_iid']."'")->find();
							
							if($goodsinfo)
							{
								$goods_stock['stock']=$goodsinfo['stock']-$order['shifa'];
								if($shouquan['group_id']){
							    	$reg=$goods->where("visitor_id in($s_str) and id=".$goodsinfo['id'])->save($goods_stock);
								}else{
									$reg=$goods->where("visitor_id = '$visitor_id' and id=".$goodsinfo['id'])->save($goods_stock);
								}
								if($reg)
								{
									$shopinfo=$shop->where("visitor_id = '$visitor_id' and shop_name='".$order['shop']."'")->find();
									
									$log['shop']=$shopinfo['id']; 
									$log['name']=$order['receiver_name'];
									$log['phone']=empty($order['receiver_phone'])?$order['receiver_mobile']:$order['receiver_mobile']." | ".$order["receiver_phone"];
									$log['address']=$order['receiver_state']." ".$order['receiver_city']." ".$order['receiver_district']." ".$order['receiver_town']." ".$order['receiver_address'];
									$log['goods_id']=$goodsinfo['id'];
									$log['outer_iid']=$order['outer_iid'];
									$log['num']=-$order['shifa'];
									$log['amount']=$order['payment'];
									$log['remarks']='手动审核减库存';
									$log['add_time']=date('Y-m-d H:i：s');
									$log['modify_time']=date('Y-m-d H:i：s');
									$log['tid']=$tid;
									$log['oid']=$order['oid'];
									$log['refund_fee']=$order['refund_fee'];
									$log['visitor_id']	 = $_SESSION['user']['id'];
									$rel=$stock->add($log);
									if($rel)
									{
										$result='true';
									}
								} 
							}
							
						}
					}
					
					
				} 
				
			}
		   
		   echo json_encode($result);
		}
		
		
    }
	
	/* 收件信息 */
	public function order_receiver()
	{
		$visitor_id = $_SESSION['user']['id'];   
		$tid=empty($_REQUEST['tid'])?0:$_REQUEST['tid'];
		$field='id,tid,receiver_name,receiver_mobile,receiver_phone,receiver_state,receiver_city,receiver_district,receiver_town,receiver_address,receiver_zip';
		$orderinfo=M('trades')->field($field)->where("visitor_id = '$visitor_id' and tid='".$tid."'")->find();
		
		$this->assign('orderinfo',$orderinfo);
		$this->display();
	}
	
	/* 收件信息修改 */
	public function order_receiver_edit()
	{
		$visitor_id = $_SESSION['user']['id']; 
		$tid=empty($_POST['tid'])?0:$_POST['tid'];
		
		$data['receiver_name']=empty($_POST['receiver_name'])?'':$_POST['receiver_name'];
		$data['receiver_mobile']=empty($_POST['receiver_mobile'])?'':$_POST['receiver_mobile'];
		$data['receiver_phone']=empty($_POST['receiver_phone'])?'':$_POST['receiver_phone'];
		$data['receiver_state']=empty($_POST['receiver_state'])?'':$_POST['receiver_state'];
		$data['receiver_city']=empty($_POST['receiver_city'])?'':$_POST['receiver_city'];
		$data['receiver_town']=empty($_POST['receiver_town'])?'':$_POST['receiver_town'];
		$data['receiver_address']=empty($_POST['receiver_address'])?'':$_POST['receiver_address'];
		
		$res=M('trades')->where("tid='$tid' and visitor_id = '$visitor_id'")->save($data);
		
		echo "<script>parent.location.reload();</script>";
	}
	
	/* 卖家备注 */
	public function order_memo()
	{
		$visitor_id = $_SESSION['user']['id']; 
		$tid=empty($_REQUEST['tid'])?0:$_REQUEST['tid'];
		$field='id,tid,seller_memo,seller_flag';
		$orderinfo=M('trades')->field($field)->where("tid='$tid' and visitor_id = '$visitor_id'")->find();
		
		$this->assign('orderinfo',$orderinfo);
		$this->display();
	}
	
	/* 卖家备注修改 */
	public function order_memo_edit()
	{
		$tid=empty($_POST['tid'])?0:$_POST['tid'];
		
		$data['seller_flag']=empty($_POST['seller_flag'])?0:$_POST['seller_flag'];
		$data['seller_memo']=empty($_POST['seller_memo'])?'':trim($_POST['seller_memo']);
		
		$res=M('trades')->where("tid='".$tid."'")->save($data);
		
		echo "<script>parent.location.reload();</script>";
	}
	
	/* 订单合并 */
	public function order_merge()
	{ 
		$visitor_id = $_SESSION['user']['id'];  
		$tid=empty($_REQUEST['tid'])?0:$_REQUEST['tid'];
		$field='id,tid,receiver_name,receiver_state,receiver_city,receiver_district,receiver_town,receiver_address';
		$orderinfo=M('trades')->field($field)->where("visitor_id = '$visitor_id' and tid='".$tid."'")->find();
		
		$receiver['receiver_name']     = $orderinfo['receiver_name'];
		$receiver['receiver_state']    = $orderinfo['receiver_state'];
		$receiver['receiver_city']     = $orderinfo['receiver_city'];
		$receiver['receiver_district'] = $orderinfo['receiver_district'];
		$receiver['receiver_address']  = $orderinfo['receiver_address'];
		
		$order_list=D('orders')->order_list_receiver($receiver); 
		
		$this->assign('order_list',$order_list);
		$this->assign('receiver',$receiver);
		$this->display();
	}
	
	
	/* 订单合并处理 */
	public function order_merge_edit()
	{
		$visitor_id = $_SESSION['user']['id'];
		$tids=empty($_POST['tids'])?'':$_POST['tids'];
		$tids=explode(',',trim($tids,','));
		
		$oids=empty($_POST['oids'])?'':trim($_POST['oids'],',');
		$oids=explode(',',$oids);
		
		$arr=array_unique($tids);
		 
		if(count($arr)==1)
		{
			$data['mid']='';
		} 
		else
		{
			$data['mid']=$tids[0];
		}
		$data['is_split']=0;
		
		//$res=M('orders')->where("oid in (".$oids.")")->save($data);
		
		foreach($oids as $oid)
		{   
			$res=M('orders')->where("oid='$oid' and visitor_id = '$visitor_id'")->save($data);
		}
		
		echo "<script>parent.location.reload();</script>";
	}
	
	/* 订单拆分 */
	public function order_split()
	{  
		$visitor_id = $_SESSION['user']['id'];   
		$tid=empty($_REQUEST['tid'])?0:$_REQUEST['tid'];
		$oid=empty($_REQUEST['oid'])?0:$_REQUEST['oid'];
		$field='t.id,t.tid,t.receiver_name,t.receiver_state,t.receiver_city,t.receiver_district,t.receiver_town,t.receiver_address,'.
		        'o.oid,o.mid';
		$orderinfo=M('trades')->alias('as t')->join('orders as o on t.tid=o.tid')->field($field)->where("o.visitor_id = '$visitor_id' and oid='".$oid."'")->find();
		
		$receiver['receiver_name']     = $orderinfo['receiver_name'];
		$receiver['receiver_state']    = $orderinfo['receiver_state'];
		$receiver['receiver_city']     = $orderinfo['receiver_city']; 
		$receiver['receiver_district'] = $orderinfo['receiver_district'];
		$receiver['receiver_address']  = $orderinfo['receiver_address'];
		
		$order_list=D('orders')->order_list_receiver($receiver,$orderinfo['mid']); 
		
		$this->assign('order_list',$order_list);
		$this->assign('receiver',$receiver);
		$this->display();
	}
	 
	/* 订单拆分处理 */
	public function order_split_edit()
	{
		$visitor_id = $_SESSION['user']['id']; 
		$tids=empty($_POST['tids'])?'':$_POST['tids'];
		$tids=explode(',',trim($tids,','));
		
		$oids=empty($_POST['oids'])?'':$_POST['oids'];
		$oids=explode(',',trim($oids,','));
		
		$data['mid']=''; 
		foreach($oids as $oid)
		{
			$res=M('orders')->where("oid='$oid' and visitor_id = '$visitor_id'")->save($data);
			
		}
		$receiver=M('trades')->field('receiver_name,receiver_state,receiver_city,receiver_district,receiver_town,receiver_address')->where("visitor_id = '$visitor_id' and tid='".$tids[0]."'")->find();
		$order_list=D('orders')->order_list_receiver($receiver);
		
		if(count($tids)==$order_list['trades_count']-1)
		{
			$ret=M('orders')->where("tid in (".$order_list['tids'].") and visitor_id = '$visitor_id'")->save($data);
		}
		
		echo "<script>parent.location.reload();</script>";
	}
	 
	/* 子订单拆分处理 */
	public function order_part_split()
	{
		$visitor_id = $_SESSION['user']['id']; 
		$tid=empty($_REQUEST['tid'])?0:$_REQUEST['tid'];
		$field='t.id,t.tid,t.title as shop,t.receiver_name,t.receiver_state,t.receiver_city,t.receiver_district,t.receiver_town,t.receiver_address,'.
		       'o.id,o.oid,o.tid,o.title,o.num_iid,o.num,o.shifa,o.payment';
		$order_list=M('trades')->alias('as t')->join('orders as o on t.tid=o.tid')->field($field)->where("t.visitor_id = '$visitor_id' and t.tid='".$tid."' and is_split=0")->select();
		
		$this->assign('order_list',$order_list);
		$this->display();
	}
	
	/* 子订单拆分处理 */
	public function order_part_split_edit()
	{
		$visitor_id = $_SESSION['user']['id'];
		$oids=empty($_POST['oids'])?'':$_POST['oids'];
		$oids=explode(',',trim($oids,','));
		 
		foreach($oids as $oid)
		{   
		    $data['mid']=$oid;
			$data['is_split']=1;
			$res=M('orders')->where("oid='$oid' and visitor_id = '$visitor_id'")->save($data);
		}
		
		echo "<script>parent.location.reload();</script>";
	}
	

   
  
	
}
















